function make_drop_target(element_id) {
    var dropContainer = document.getElementById("container");
    dropContainer.addEventListener("drop",dropHandler,false);
    dropContainer.addEventListener("dragenter", function(event){event.stopPropagation();event.preventDefault();}, false);
    dropContainer.addEventListener("dragover", function(event){event.stopPropagation();event.preventDefault();}, false);
    dropContainer.addEventListener("drop", dropHandler, false);
}
function dropHandler(event){
    var files = event.dataTransfer.files;
    var count = files.length;
    form = new FormData();
    for(var i= 0;i<count;i++){
        form.append("file"+i, files[i]);
    }
    sendData(form);
}
function sendData(form){
    var xhr = new XMLHttpRequest();  
    xhr.upload.addEventListener("progress", uploadProgress, false);  
    xhr.addEventListener("load", uploadComplete, false);
    xhr.addEventListener("error", uploadFailed, false);  
    xhr.open("POST", "/upload.php");
    xhr.send(form);
    var progressBar = document.getElementById('progressBar');
    progressBar.style.display = 'block';
    progressBar.style.width = '0px';

    function uploadComplete(event){
        document.getElementById('per').innerHTML="";
        rst = eval('a=' + xhr.responseText);
        window.location.href = 'mark.html?pid='+rst.id;
        //getResult();
        //$.jGrowl('<font  face="Microsoft YaHei">上传成功!</font>');
    }
}

function uploadFailed(event){
}
function uploadProgress(event){
    var percentComplete;
    if(event.lengthComputable){
        percentComplete = Math.round(event.loaded * 100 / event.total);
    }
    document.getElementById('progressBar').style.width = (percentComplete * 8.8).toString() + 'px';

    if(percentComplete==100){
        document.getElementById('progressBar').style.width = (0 * 8.8).toString() + 'px';
    }
    document.getElementById('per').innerHTML=percentComplete+"%";
}
